(function(){"use strict";BX.namespace("BX.Filter");BX.Filter.DestinationSelectorManager={fields:[],controls:{},onSelect:function(t,e,i){if(!BX.type.isNotEmptyObject(i)||!BX.type.isNotEmptyObject(i.item)||!BX.type.isNotEmptyString(i.selectorId)){return}var n=i.selectorId,o=i.item;var r=BX.Filter.DestinationSelectorManager.controls[n];if(r){var s=o.id;if(BX.type.isNotEmptyString(t)&&t=="Y"&&BX.type.isNotEmptyString(e)){var l=new RegExp("^"+e+"(\\d+)$");var d=s.match(l);if(BX.type.isArray(d)){s=d[1]}}else{var a={};BX.onCustomEvent(window,"BX.Filter.DestinationSelector:convert",[{selectorId:n,value:s},a]);if(BX.type.isNotEmptyString(a.value)){s=a.value}}r.setData(BX.util.htmlspecialcharsback(o.name),s);r.getLabelNode().value="";r.getLabelNode().blur()}},onDialogOpen:function(t){if(typeof t=="undefined"||!BX.type.isNotEmptyString(t.selectorId)){return}var e=t.selectorId;var i=BX.Filter.DestinationSelector.items[e];if(i){i.onDialogOpen()}},onDialogClose:function(t){if(typeof t=="undefined"||!BX.type.isNotEmptyString(t.selectorId)){return}var e=t.selectorId;var i=BX.Filter.DestinationSelector.items[e];if(i){i.onDialogClose()}}};BX.Filter.DestinationSelector=function(){this.id="";this.filterId="";this.settings={};this.fieldId="";this.control=null;this.inited=null};BX.Filter.DestinationSelector.items={};BX.Filter.DestinationSelector.create=function(t,e){if(typeof this.items[t]!="undefined"){return this.items[t]}var i=new BX.Filter.DestinationSelector(t,e);i.initialize(t,e);this.items[t]=i;BX.onCustomEvent(window,"BX.Filter.DestinationSelector:create",[t]);return i};BX.Filter.DestinationSelector.prototype.getSetting=function(t,e){return this.settings.hasOwnProperty(t)?this.settings[t]:e};BX.Filter.DestinationSelector.prototype.getSearchInput=function(){return this.control?this.control.getLabelNode():null};BX.Filter.DestinationSelector.prototype.initialize=function(t,e){this.id=t;this.settings=e?e:{};this.fieldId=this.getSetting("fieldId","");this.filterId=this.getSetting("filterId","");this.inited=false;this.opened=null;var i=this.getSetting("initialValue",false);if(!!i){var n={};n[this.fieldId]=i.itemId;n[this.fieldId+"_label"]=i.itemName;BX.Main.filterManager.getById(this.filterId).getApi().setFields(n)}BX.addCustomEvent(window,"BX.Main.Filter:customEntityFocus",BX.delegate(this.onCustomEntitySelectorOpen,this));BX.addCustomEvent(window,"BX.Main.Filter:customEntityBlur",BX.delegate(this.onCustomEntitySelectorClose,this));BX.addCustomEvent(window,"BX.Main.Filter:onGetStopBlur",BX.delegate(this.onGetStopBlur,this));BX.addCustomEvent(window,"BX.Main.SelectorV2:beforeInitDialog",BX.delegate(this.onBeforeInitDialog,this));BX.addCustomEvent(window,"BX.Main.Filter:customEntityRemove",BX.delegate(this.onCustomEntityRemove,this))};BX.Filter.DestinationSelector.prototype.open=function(){var t=this.id;if(!this.inited){var e=this.getSearchInput();e.id=e.name;BX.addCustomEvent(window,"BX.Main.SelectorV2:afterInitDialog",BX.delegate(function(t){if(typeof t.id!="undefined"||t.id!=this.id){return}this.opened=true},this));BX.addCustomEvent(window,"BX.UI.SelectorManager:onCreate",BX.delegate(function(t){if(!BX.type.isNotEmptyString(t)||t!=this.id){return}BX.onCustomEvent(window,"BX.Filter.DestinationSelector:setSelected",[{selectorId:t,current:this.control.getCurrentValues()}])},this));BX.onCustomEvent(window,"BX.Filter.DestinationSelector:openInit",[{id:this.id,inputId:e.id,containerId:e.id}])}else{var i={};i[this.currentUser.entityId]="users";BX.onCustomEvent(window,"BX.Filter.DestinationSelector:open",[{id:this.id,bindNode:this.control.getField(),value:i}]);this.opened=true}};BX.Filter.DestinationSelector.prototype.close=function(){if(typeof BX.Main.selectorManagerV2.controls[this.id]!=="undefined"){BX.Main.selectorManagerV2.controls[this.id].closeDialog()}};BX.Filter.DestinationSelector.prototype.onCustomEntitySelectorOpen=function(t){var e=t.getId();if(this.fieldId!==e){this.control=null}else{this.control=t;if(this.control){var i=this.control.getCurrentValues();this.currentUser={entityId:i["value"]}}BX.Filter.DestinationSelectorManager.controls[this.id]=this.control;if(!this.opened){this.open()}else{this.close()}}};BX.Filter.DestinationSelector.prototype.onCustomEntitySelectorClose=function(t){if(this.fieldId===t.getId()&&this.inited===true&&this.opened===true){this.control=null;window.setTimeout(BX.delegate(this.close,this),0)}};BX.Filter.DestinationSelector.prototype.onGetStopBlur=function(t,e){if(BX.findParent(t.target,{className:"bx-lm-box"})){e.stopBlur=true}};BX.Filter.DestinationSelector.prototype.onCustomEntityRemove=function(t){if(this.fieldId===t.getId()){var e=BX.UI.SelectorManager.instances[t.getId()];if(e&&typeof t.hiddenInput!="undefined"&&typeof t.hiddenInput.value!="undefined"&&BX.type.isNotEmptyObject(e.itemsSelected)&&typeof e.itemsSelected[t.hiddenInput.value]!="undefined"){delete e.itemsSelected[t.hiddenInput.value]}}};BX.Filter.DestinationSelector.prototype.onBeforeInitDialog=function(t){if(typeof t.id=="undefined"||t.id!=this.id){return}this.inited=true;if(!this.control){t.blockInit=true}};BX.Filter.DestinationSelector.prototype.onDialogOpen=function(){this.opened=true};BX.Filter.DestinationSelector.prototype.onDialogClose=function(){this.opened=false}})();
//# sourceMappingURL=destination-selector.map.js